package com.boarsoft.boar.soagov.face.action;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.boarsoft.bean.ReplyInfo;
import com.boarsoft.boar.entity.FaceParam;
import com.boarsoft.boar.soagov.face.FaceParamBiz;
import com.boarsoft.common.Authorized;
import com.boarsoft.common.Util;
import com.boarsoft.common.dao.PagedResult;

@RestController
@RequestMapping("/face/param")
public class FaceParamAction {
	@Autowired
	private FaceParamBiz faceParamBiz;

	/**
	 * 按接口ID查询所有的参数<br/>
	 */
	@RequestMapping("/list.do")
	@Authorized(code = "face.param.list")
	public ReplyInfo<Object> list(String id, String faceId, Short flag, int pageNo, int pageSize) {
		if (Util.strIsEmpty(faceId)) {
			// String[] faceIds = id.split(",");
			// id = 'xxxxx','xxxxx'
			List<FaceParam> lt = faceParamBiz.listOutputOf(id);
			return new ReplyInfo<Object>(true, lt);
		}
		PagedResult<FaceParam> pr = faceParamBiz.list(faceId, flag, pageNo, pageSize);
		return new ReplyInfo<Object>(true, pr);
	}

	@RequestMapping("/save")
	@Authorized(code = "face.param.save")
	public ReplyInfo<Object> save(FaceParam c) {
		return faceParamBiz.save(c);
	}

	@RequestMapping("/delete.do")
	@Authorized(code = "face.param.delete")
	public ReplyInfo<Object> delete(String id) {
		faceParamBiz.delete(id);
		return ReplyInfo.SUCCESS;
	}

	@RequestMapping("/get.do")
	@Authorized(code = "face.param.get")
	public ReplyInfo<Object> get(String id) {
		FaceParam a = faceParamBiz.get(id);
		return new ReplyInfo<Object>(true, a);
	}
}